<%--
  Created by IntelliJ IDEA.
  User: 20459
  Date: 2023/4/11
  Time: 20:48
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>SAMSUNG三星商城后台</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <link rel="shortcut icon" href="../x-admin/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="../x-admin/css/font.css">
    <link rel="stylesheet" href="../x-admin/css/xadmin.css">
    <link rel="stylesheet" href="https://cdn.bootcss.com/Swiper/3.4.2/css/swiper.min.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript" src="https://cdn.bootcss.com/Swiper/3.4.2/js/swiper.jquery.min.js"></script>
    <script src="../x-admin/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../x-admin/js/xadmin.js"></script>
</head>
<body>
<table class="layui-table" id="LAY-user-table">
    <thead>
    <tr>
        <th>
            详情ID
        </th>
        <th>
            名称
        </th>
        <th>
            颜色
        </th>
        <th>
            内存
        </th>
        <th>
            价格
        </th>
        <th>
            操作
        </th>
    </tr>
    </thead>
    <tbody>
    <c:forEach items="${goodsxq}" var="x">
        <tr>
            <td>
                    ${x.sxid}
            </td>
            <td>
                    ${x.commodity.sname}
            </td>
            <td>
                    ${x.commoditycolor.yname}
            </td>
            <td >
                    ${x.commoditymemory.nname}
            </td>
            <td >
                    ${x.xprice}
            </td>
            <td class="td-manage">
                <a style="text-decoration:none"  onclick="member_edit('修改价格','goodsxqedit?xprice=${x.xprice}&sxid=${x.sxid}','10001','600','400')"
                   href="javascript:;" title="修改价格">
                    <i class="layui-icon" style="font-size: 20px">&#xe631;</i>
                </a>
                <a title="删除" href="javascript:;" onclick="member_del(this,${x.sxid})"
                   style="text-decoration:none">
                    <i class="layui-icon" style="font-size: 20px">&#xe640;</i>
                </a>
            </td>
        </tr>
    </c:forEach>
    </tbody>
</table>
<script>
    /*价格-修改*/
    function member_edit(title,url,id,w,h){
        x_admin_show(title,url,w,h);
    }

    /*用户-删除*/
    function member_del(obj,id){
        layer.confirm('确认要删除吗？',function(index){
            //发异步删除数据
            $(obj).parents("tr").remove();
            console.log("要删除的id="+id);
            if (id!=null) {
                $.ajax({
                    url: "/goodsxq?v=delgoodsxq",
                    type: "post",
                    data: {
                        id
                    },
                    success: (r => {
                        if (r > 0) {
                            layer.msg("已删除！", {icon: 1, time: 1000}, function () {
                                // 获得frame索引
                                var index = parent.layer.getFrameIndex(window.name);
                                //关闭当前frame
                                parent.layer.close(index);
                                //修改成功后刷新父界面
                                window.parent.location.reload();
                            });
                        } else {
                            layer.msg("删除失败!！", {icon: 2 ,time: 1000});
                            window.setTimeout(function () {
                                window.location.reload();
                            },1000)
                        }
                    })
                })
            }else{
                console.log("要删除的id为空!!");
            }
        });
    }

</script>
</body>
</html>
